package com.qf.electronic.mall.search.web.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qf.dto.ResultBean;
import com.qf.search.api.ISearchService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("search")
public class SearchController {
    @Reference
    private ISearchService searchService;

    @RequestMapping("")
    public String searchByKeyword(String keyword, Model model){
        ResultBean resultBean = searchService.searchByKeyword(keyword);
        model.addAttribute("products",resultBean.getData());
        return "search";
    }

    @RequestMapping("addProduct")
    public ResultBean addProduct(Long pid){
        return searchService.addProduct(pid);
    }
}
